def fun(n,k):
    path=[]
    result=[]
    def backtracking(n,k,startIndex):
        if len(path)==k:
            result.append(path[:])
            return result
        for i in range(startIndex,n+1):
            path.append(i);
            backtracking(n,k,i+1)
            path.pop()
    backtracking(n,k,1)
    return result
res=fun(4,2)
print(res)